import {
  ObjectOnlyPushSet,
  removeObjectOnlyPushSet,
} from '../../../Func/uniFunc/Func';
import {
  uni_static_micro_tasks_mana_prop_namespace,
  win_static_micro_tasks_mana_prop_namespace,
  win_static_prop_micro_tasks_mana,
} from '../DataDefine/sourceData';
import { taskList } from './taskList/Classes/cla_taskList';

const uni_static_micro_tasks_manaTag = 'uni_static_micro_tasks_mana';

const uni_static_micro_tasks_mana_prop_task_list = 'tasks_list';

class uni_static_micro_tasks_mana {
  get [Symbol.toStringTag]() {
    return uni_static_micro_tasks_manaTag;
  }

  constructor() {}

  /**
   * 命名 空间
   * @type {string}
   */
  [uni_static_micro_tasks_mana_prop_namespace];

  /**
   * 任务 列 名 集合
   */
  [uni_static_micro_tasks_mana_prop_task_list] = [];

  /**
   * 新创建 一个 taskList
   * @param {string} taskName
   */
  create_new_taskList(taskName) {
    let ret = new taskList(taskName);
    ObjectOnlyPushSet(
      this,
      taskName,
      ret,
      uni_static_micro_tasks_mana_prop_task_list
    );

    return ret;
  }

  /**
   * 删除 window 上的 信息
   */
  destroy() {
    removeObjectOnlyPushSet(
      window[win_static_prop_micro_tasks_mana],
      this[uni_static_micro_tasks_mana_prop_namespace],
      true,
      win_static_micro_tasks_mana_prop_namespace
    );
  }
}

export { uni_static_micro_tasks_mana };
